<style>
<!--
.data-row {
	cursor: pointer;
}
-->
</style>
<table class="project-list" data-page="${page}" data-count="${count}" data-page-size="${pageSize}">
	<tr class="title-row">
		<th class="text-center" style="min-width: 120px;">项目编号</th>
		<th class="text-center">项目名称</th>
		<th class="text-center">签约单位</th>
		<th class="text-center" width="70">工程实施情况</th>
		<th class="text-center" width="70">项目经理</th>
		<th class="text-center">合同金额</th>
		<th class="text-center">结算金额</th>
		<th class="text-center">收款金额</th>
		<th class="text-center">支出金额</th>
		<th class="text-center">未收金额（比例）</th>
		<th class="text-center">利润（比例）</th>
	</tr>
	<#if data??> <#list data as d >
	<tr data-id="${d.id}">
		<td class="data-row" onclick="window.open('${request.contextPath}/project/form?id=${d.id}', '_blank')">${d.no}</td>
		<td class="data-row" onclick="window.open('${request.contextPath}/project/form?id=${d.id}', '_blank')">${d.name}</td>
		<td>${d.customerCompany}</td>
		<td class="text-center">${d.status.val}</td>
		<td class="text-center">${(d.manager.name)!'-'}</td>
		<td>${(d.mainContract.price?string('currency'))!'-'}</td>
		<td>${(d.mainContract.payPrice?string('currency'))!'-'}</td>
		<td>${(d.mainContract.paymentCount?string('currency'))!'-'}</td>
		<td>${(d.costCount?string('currency'))!'-'}</td>
		<td>
			${(d.mainContract.notPaymentCount?string('currency'))!'-'}
			<br>
			<span class="text-danger">（${(d.mainContract.notPaymentRatio?string('percent'))!'-'}）</span>
		</td>
		<td>
			${(d.profit?string('currency'))!'-'}
			<br>
			<span class="text-danger">（${(d.profitRatio?string('percent'))!'-'}）</span>
		</td>
	</tr>
	</#list> </#if> <#if total??>
	<tr class="not-content-row no-checkbox">
		<td colspan="5" class="text-center">合计</td>
		<td>${(total['price']?string('currency'))!'-'}</td>
		<td>${(total['payPrice']?string('currency'))!'-'}</td>
		<td>${(total['payIn']?string('currency'))!'-'}</td>
		<td>${(total['payOut']?string('currency'))!'-'}</td>
		<td>${((total['payPrice'] - total['payIn'])?string('currency'))!'-'}</td>
		<td>${((total['payPrice'] - total['payOut'])?string('currency'))!'-'}</td>
	</tr>
	</#if>
</table>

<script src="${request.contextPath}/js/suredy-list.js"></script>
<script type="text/javascript">
	$(function() {
		var btns = [];
		<#if Session['proj_creater']>
		btns[btns.length] = {
			text : '新建项目',
			icon : 'icon-plus',
			style : 'btn-warning',
			click : function() {
				window.open('${request.contextPath}/project/form');
			}
		};
		</#if>
		<#if Session['proj_deleter']>
		btns[btns.length] = {
			text : '删除',
			icon : 'icon-plus',
			style : 'btn-danger',
			click : function() {
				var checked = $.suredy.list.checked($('table.project-list'));

				if (checked.length === 0) {
					return false;
				}

				if (!window.confirm('确定删除[' + checked.length + ']条项目信息？'))
					return false;

				var id = [];
				checked.each(function(i) {
					id[i] = $(this).data('id');
				});

				var uri = $.suredy.contextPath + '/project/list/delete';

				$.ajax({
					url : uri,
					type : 'post',
					traditional : true,
					data : {
						id : id
					},
					success : function(success, textStatus, jqXHR) {
						if (!success) {
							alert('删除操作失败！');
							return false;
						}

						var listUri = $.suredy.contextPath + '/project/list';

						$.suredy.loadContent(listUri);
					},
					error : function(jqXHR, textStatus, errorThrown) {
						alert('删除操作失败！\n' + errorThrown);
					}
				});

			}
		};
		</#if>

		$('table.project-list').list({
			searchValue : '${key!""}',
			checkbox : ${Session['proj_deleter']?string('true','false')},
			paginate : function(page, pageSize, key) {
				$.suredy.loadContent('${request.contextPath}/project/list', false, {
					page : page,
					pageSize : pageSize,
					search : key
				});
			},
			btns : btns
		});
	});
</script>